<?php


namespace Part24_IntermediaryModel\Code1;

/**
 * 管理者
 */
class Manager
{
    protected $name;

    public function __construct($name)
    {
        $this->name = $name;
    }

    /**
     * 方法比较长，分支很多，都是代码的坏味道
     * @param $managerLevel
     * @param $request Request
     */
    public function getResult($managerLevel, $request)
    {
        if ($managerLevel == '经理') {
            if ($request->getType() == '请假' && $request->getNum() <= 2) {
                echo "{$this->name}：已批准{$request->getType()}{$request->getNum()}\n";
            }else{
                echo "{$this->name}：没权利审批{$request->getType()}{$request->getNum()}\n";
            }
        }elseif($managerLevel == '总监'){
            if ($request->getType() == '请假' && $request->getNum() <= 5) {
                echo "{$this->name}：已批准{$request->getType()}{$request->getNum()}\n";
            }else{
                echo "{$this->name}：没权利审批{$request->getType()}{$request->getNum()}\n";
            }
        }elseif($managerLevel == '总经理'){
            if ($request->getType() == '请假') {
                echo "{$this->name}：已批准{$request->getType()}{$request->getNum()}\n";
            }elseif ($request->getType() == '加薪' && $request->getNum() <= 500){
                echo "{$this->name}：已通过{$request->getType()}{$request->getNum()}块申请\n";
            }elseif ($request->getType() == '加薪' && $request->getNum() > 500){
                echo "{$this->name}：{$request->getType()}{$request->getNum()}块？？？ 以后再说吧\n";
            }
        }
    }
}